using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Storage;

namespace Halloween_Game
{
    class Simple_Camera
    {
        //This variable holds the position of the camera
        private Vector2 camPosition;

        public Vector2 CamPosition
        {
            get { return camPosition; }
            set { camPosition = value; }
        }

        private Vector2 velocity;

        public Vector2 Velocity
        {
            get { return velocity; }
            set { velocity = value; }
        }

        private Vector2 camDimension;

        public Vector2 CamDimension
        {
            get { return camDimension; }
            set { camDimension = value; }
        }

        private Vector2 camBoundary;

        public Vector2 CamBoundary
        {
            get { return camBoundary; }
            set { camBoundary = value; }
        }
	
	


        /// <summary>
        /// Creates and initializes a simple_camera, sets initial position and camPosition to vector.zero
        /// </summary>
        public Simple_Camera( Vector2 dimension )
        {
            this.CamPosition = Vector2.Zero;
            this.Velocity = Vector2.Zero;
            this.CamDimension = dimension;
        }

        /// <summary>
        /// Returns true if the position is out bounds of the camera, false otherwise
        /// </summary>
        /// <param name="position"></param>
        /// <returns>true if the given position is out of the camera range, false otherwise</returns>
        public bool atBounds( Vector2[] positions )
        {

            //For each position, check if there is an out of bounds violation
            for (int i = 0; i < positions.Length; i += 2 )
            {
                float width = positions[i + 1].X - positions[i].X;
                float height = positions[i + 1].Y - positions[i].Y;
                //checks to see if the current position is at a violating position
                if (positions[i].X < 0)
                {
                    return true;
                }

                if (positions[i].X + positions[i+1].X > this.CamDimension.X)
                {
                    return true;
                }

                if (positions[i].Y < 0)
                {
                    return true;
                }

                if (positions[i].Y + positions[i+1].Y > this.CamDimension.Y)
                {
                    return true;
                }
            }//end of foreach loop

            //None of the positions are out of bounds
            return false;
        } //End of atBounds method
    }
}
